<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>js表格变色制作表格各行变色,滑过选中变色特效</title>
<meta name="description" content="js表格特效制作js表格变色效果，表格各行变色，鼠标滑过显示单行变色效果，点击选中变色。内含js代码下载。" />

<style type="text/css">
*{margin:0;padding:0;list-style-type:none;}
a,img{border:0;}
table{empty-cells:show;border-collapse:collapse;border-spacing:0;}
#grid td,#grid th{padding:5px;border:#E3E3E3 1px solid;font-size:12px;height:16px;line-height:16px;}
#grid tr td span{color:#686868;}
#grid tr td.st1{color:#ff0000}
</style>

<script type="text/javascript">
function grid(o,a,b,c,d){

	var t=document.getElementById(o).getElementsByTagName("tr");

	for(var i=0;i<t.length;i++){
		
		t[i].style.backgroundColor=(t[i].sectionRowIndex%2==0)?a:b;
		
		t[i].onclick=function(){
			if(this.x!="1"){
				this.x="1";
				this.style.backgroundColor=d;
			}else{
				this.x="0";
				this.style.backgroundColor=(this.sectionRowIndex%2==0)?a:b;
			}
		}

		t[i].onmouseover=function(){
			if(this.x!="1")this.style.backgroundColor=c;
		}
		
		t[i].onmouseout=function(){
			if(this.x!="1")this.style.backgroundColor=(this.sectionRowIndex%2==0)?a:b;
		}
	}
}
</script>

</head>
<body>

<table width="550" id="grid">
	<tr>
		<td colspan="4" class="st1">
			<span><a href="http://www.jsfoot.com/" target="_blank">js特效</a></span>
			当前页：
			<span>第1页 共2页 </span>
			总次数：
			<span>66</span>
			总时长：
			<span>284小时36分27秒</span>
		</td>
	</tr>
	<tr>
		<th>接入方式</th><th>上网时间</th><th>下网时间</th><th>上网时长</th>
	</tr>
	<tr>
		<td>ASP</td>
		<td>2008-4-23　12:40:18</td>
		<td>2008-4-23　14:50:28</td>
		<td>2小时10分10秒</td>
	</tr>
	<tr>
		<td>PHP</td>
		<td>2008-4-23　12:40:18</td>
		<td>2008-4-23　14:50:28</td>
		<td>2小时10分10秒</td>
	</tr>
	<tr>
		<td>JSP</td>
		<td>2008-4-23　12:40:18</td>
		<td>2008-4-23　14:50:28</td>
		<td>2小时10分10秒</td>
	</tr>
	<tr>
		<td>HTML</td>
		<td>2008-4-23　12:40:18</td>
		<td>2008-4-23　14:50:28</td>
		<td>2小时10分10秒</td>
	</tr>
</table>

<script type="text/javascript">
//grid("名称","奇数行背景","偶数行背景","鼠标经过背景","点击后背景");
grid("grid","#fff","#F5F5F5","#FFFFCC","#0066CC");
</script>

</body>
</html>